<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>ArNetworking: drawingsExample.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">ArNetworking
   &#160;<span id="projectnumber">dev20180125</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('drawingsExample_8cpp-example.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">drawingsExample.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>Example showing how to draw custom graphics in clients such as MobileEyesThis is an example server that shows how to draw arbitrary figures in a client (e.g. MobileEyes) via <a class="el" href="classArServerInfoDrawings.html" title="Service to provide clients with information about graphical figures to be displayed with the map...">ArServerInfoDrawings</a>. It draws some lines, "arrows", and moving dots with various sizes and colors. You can use these drawings for debugging or visualization, for example, to represent sensor readings. In fact, specific support for <a class="elRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html">ArRobot</a>, <a class="elRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArSick.html">ArSick</a>, <a class="elRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArSonarDevice.html">ArSonarDevice</a>, <a class="elRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArIRs.html">ArIRs</a> and <a class="elRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBumpers.html">ArBumpers</a> are built in to <a class="el" href="classArServerInfoDrawings.html" title="Service to provide clients with information about graphical figures to be displayed with the map...">ArServerInfoDrawings</a>: see <a class="el" href="drawingsExampleWithRobot_8cpp.html">drawingsExampleWithRobot.cpp</a> or <a class="el" href="serverDemo_8cpp.html">serverDemo.cpp</a>.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="drawingsExampleWithRobot_8cpp.html">drawingsExampleWithRobot.cpp</a></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;Aria.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="ArNetworking_8h.html">ArNetworking.h</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &lt;math.h&gt;</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">/* These are some callbacks that respond to client requests for the drawings&#39; </span></div><div class="line"><span class="comment"> * geometry data. */</span></div><div class="line"><span class="keywordtype">void</span> <a name="a0"></a><a class="code" href="drawingsExample_8cpp.html#a7c8ed01400d514a7b9105b92c325f26a">exampleHomeDrawingNetCallback</a>(<a name="_a1"></a><a class="code" href="classArServerClient.html">ArServerClient</a>* <a name="a2"></a><a class="code" href="changeMapOnServer_8cpp.html#afe594bfb305907ae82f259409cc214cb">client</a>, <a name="_a3"></a><a class="code" href="classArNetPacket.html">ArNetPacket</a>* requestPkt);</div><div class="line"><span class="keywordtype">void</span> <a name="a4"></a><a class="code" href="drawingsExample_8cpp.html#a829cc347fa8f03be4f7e21f52a56b23d">exampleDotsDrawingNetCallback</a>(<a class="code" href="classArServerClient.html">ArServerClient</a>* <a class="code" href="changeMapOnServer_8cpp.html#afe594bfb305907ae82f259409cc214cb">client</a>, <a class="code" href="classArNetPacket.html">ArNetPacket</a>* requestPkt);</div><div class="line"><span class="keywordtype">void</span> <a name="a5"></a><a class="code" href="drawingsExample_8cpp.html#ae35734c611c1c0f5e9bc6287f5eee070">exampleXDrawingNetCallback</a>(<a class="code" href="classArServerClient.html">ArServerClient</a>* <a class="code" href="changeMapOnServer_8cpp.html#afe594bfb305907ae82f259409cc214cb">client</a>, <a class="code" href="classArNetPacket.html">ArNetPacket</a>* requestPkt);</div><div class="line"><span class="keywordtype">void</span> <a name="a6"></a><a class="code" href="drawingsExample_8cpp.html#abab39eb1a7fa3903841c77dabeb465f9">exampleArrowsDrawingNetCallback</a>(<a class="code" href="classArServerClient.html">ArServerClient</a>* <a class="code" href="changeMapOnServer_8cpp.html#afe594bfb305907ae82f259409cc214cb">client</a>, <a class="code" href="classArNetPacket.html">ArNetPacket</a>* requestPkt);</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">/* This class shows how to encapsulate the various aspects of a drawing into one</span></div><div class="line"><span class="comment"> * object that other parts of the program can easily access in a more general</span></div><div class="line"><span class="comment"> * (and thread-safe) way. It lets you change position, radius, resolution</span></div><div class="line"><span class="comment"> * (number of dots), and dot drawing properties.</span></div><div class="line"><span class="comment"> * The default radius is 1 meter and the default number of points is 360.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * In this example program, the radius is updated periodically by a loop in the</span></div><div class="line"><span class="comment"> * main thread (see main() function), while ArNetworking requests are handled</span></div><div class="line"><span class="comment"> * in the separate ArNetworking server thread, calling drawingServerCB() callback (this is </span></div><div class="line"><span class="comment"> * registered with the server when we register the drawing with the</span></div><div class="line"><span class="comment"> * ArServerInfoDrawings object).  So note the use of an ArMutex object to</span></div><div class="line"><span class="comment"> * control this asyrchronous access to the reply packet.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keyword">class </span><a name="_a7"></a><a class="code" href="classCircle.html">Circle</a></div><div class="line">{</div><div class="line"><span class="keyword">private</span>:</div><div class="line">  <a class="code" href="classArNetPacket.html">ArNetPacket</a> myReply;</div><div class="line">  <a name="_a8"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArMutex.html">ArMutex</a> myMutex; <span class="comment">// mutex around myReply</span></div><div class="line">  <a name="_a9"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArPose.html">ArPose</a> myPos;</div><div class="line">  <span class="keywordtype">double</span> myRadius;</div><div class="line">  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> myNumPoints;</div><div class="line">  <span class="keywordtype">void</span> drawingServerCB(<a class="code" href="classArServerClient.html">ArServerClient</a> *<a class="code" href="changeMapOnServer_8cpp.html#afe594bfb305907ae82f259409cc214cb">client</a>, <a class="code" href="classArNetPacket.html">ArNetPacket</a> *pkt);</div><div class="line">  <a name="_a10"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArFunctor2C.html">ArFunctor2C&lt;Circle, ArServerClient*, ArNetPacket*&gt;</a> callback;</div><div class="line">  <span class="keywordtype">void</span> regenerate();</div><div class="line"><span class="keyword">public</span>:</div><div class="line">  <a name="a11"></a><a class="code" href="classCircle.html#a02dd4e6afe1df5a16b1f3ee2ae5b8051">Circle</a>(<a name="_a12"></a><a class="code" href="classArServerInfoDrawings.html">ArServerInfoDrawings</a> *drawingsServer, <span class="keyword">const</span> std::string&amp; name, <a name="_a13"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArDrawingData.html">ArDrawingData</a> *drawData);</div><div class="line">  <a name="a14"></a><a class="code" href="classCircle.html#ae3f30436e645d73e368e8ee55f8d1650">~Circle</a>();</div><div class="line"></div><div class="line">  <span class="keywordtype">void</span> <a name="a15"></a><a class="code" href="classCircle.html#a82bb144f4d47fec91a79a946bcbb4831">setPos</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArPose.html">ArPose</a>&amp; p) </div><div class="line">  {</div><div class="line">    myPos = p;</div><div class="line">    regenerate();</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordtype">void</span> <a name="a16"></a><a class="code" href="classCircle.html#a6c5164e476c4dc5133e8a1615a0a8d75">setRadius</a>(<span class="keywordtype">double</span> r)</div><div class="line">  {</div><div class="line">    myRadius = r;</div><div class="line">    regenerate();</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordtype">void</span> <a name="a17"></a><a class="code" href="classCircle.html#a36fd9cf27d46824f293088fd0545fa91">setNumPoints</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> r)</div><div class="line">  {</div><div class="line">    myNumPoints = r;</div><div class="line">    regenerate();</div><div class="line">  }</div><div class="line"></div><div class="line">};</div><div class="line"></div><div class="line"><a class="code" href="classCircle.html#a02dd4e6afe1df5a16b1f3ee2ae5b8051">Circle::Circle</a>(<a class="code" href="classArServerInfoDrawings.html">ArServerInfoDrawings</a> *drawingsServer, <span class="keyword">const</span> std::string&amp; name, <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArDrawingData.html">ArDrawingData</a>* drawData) :</div><div class="line">  myRadius(1000.0),</div><div class="line">  myNumPoints(360),</div><div class="line">  callback(this, &amp;<a class="code" href="classCircle.html">Circle</a>::drawingServerCB)</div><div class="line">{</div><div class="line">  drawingsServer-&gt;<a name="a18"></a><a class="code" href="classArServerInfoDrawings.html#a593c3d93e722ab316ab6404c7f734011">addDrawing</a>(drawData, name.c_str(), &amp;callback);</div><div class="line">}</div><div class="line"></div><div class="line"><a class="code" href="classCircle.html#ae3f30436e645d73e368e8ee55f8d1650">Circle::~Circle</a>() </div><div class="line">{</div><div class="line">  <span class="comment">// TODO remove drawing from the server, but not implemented yet</span></div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> Circle::drawingServerCB(<a class="code" href="classArServerClient.html">ArServerClient</a> *<a class="code" href="changeMapOnServer_8cpp.html#afe594bfb305907ae82f259409cc214cb">client</a>, <a class="code" href="classArNetPacket.html">ArNetPacket</a> *pkt)</div><div class="line">{</div><div class="line">  myMutex.<a name="a19"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArMutex.html#a7b6aee74872c19fb8829d96dc3e52f34">lock</a>();</div><div class="line">  client-&gt;<a name="a20"></a><a class="code" href="classArServerClient.html#a9276b1f38501725852c779058bad1d33">sendPacketUdp</a>(&amp;myReply);</div><div class="line">  myMutex.<a name="a21"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArMutex.html#afb51b5514a9456f23441e479fe58fb46">unlock</a>();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// Method called by accessor methods when properties changed. This reconstructs</span></div><div class="line"><span class="comment">// the myReply packet sent in response to requests from clients</span></div><div class="line"><span class="keywordtype">void</span> Circle::regenerate()</div><div class="line">{</div><div class="line">  myMutex.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArMutex.html#a7b6aee74872c19fb8829d96dc3e52f34">lock</a>();</div><div class="line">  myReply.<a name="a22"></a><a class="code" href="classArNetPacket.html#a967d1901ff4e9cc53e31383eaa3bb609">empty</a>();</div><div class="line">  myReply.<a name="a23"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(myNumPoints);</div><div class="line">  <span class="keywordtype">double</span> a = 360.0/myNumPoints;</div><div class="line">  <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; myNumPoints; ++i)</div><div class="line">  {</div><div class="line">    myReply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(<a name="a24"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArMath.html#a5cc85672a327b96f1668aaf8efc58c7a">ArMath::roundInt</a>(myPos.<a name="a25"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArPose.html#afd85bde3b0320d19d108b172c3f332b1">getX</a>()+<a name="a26"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#ga953ffdd0b569b33cbfd5a8f69cf3c69a">ArMath::cos</a>(i*a)*myRadius)); <span class="comment">// X</span></div><div class="line">    myReply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArMath.html#a5cc85672a327b96f1668aaf8efc58c7a">ArMath::roundInt</a>(myPos.<a name="a27"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArPose.html#a563e9580f307fe832a7269f72bfda8fb">getY</a>()+<a name="a28"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#gaeb05754b7747988dd97a961eaded6830">ArMath::sin</a>(i*a)*myRadius)); <span class="comment">// Y</span></div><div class="line">  }</div><div class="line">  myMutex.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArMutex.html#afb51b5514a9456f23441e479fe58fb46">unlock</a>();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> <a name="a29"></a><a class="code" href="drawingsExample_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div><div class="line">{</div><div class="line">  <a name="a30"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#ad99c16b5d947229d9f8e1c5b2d4cdd73">Aria::init</a>();</div><div class="line">  <a name="_a31"></a><a class="code" href="classArServerBase.html">ArServerBase</a> server;</div><div class="line"></div><div class="line">  <a name="_a32"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArArgumentParser.html">ArArgumentParser</a> parser(&amp;argc, argv);</div><div class="line">  <a name="_a33"></a><a class="code" href="classArServerSimpleOpener.html">ArServerSimpleOpener</a> simpleOpener(&amp;parser);</div><div class="line"></div><div class="line">  <span class="comment">// parse the command line... fail and print the help if the parsing fails</span></div><div class="line">  <span class="comment">// or if help was requested</span></div><div class="line">  parser.loadDefaultArguments();</div><div class="line">  <span class="keywordflow">if</span> (!simpleOpener.parseArgs() || !parser.checkHelpAndWarnUnparsed())</div><div class="line">  {    </div><div class="line">    simpleOpener.logOptions();</div><div class="line">    exit(1);</div><div class="line">  }</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// first open the server up</span></div><div class="line">  <span class="keywordflow">if</span> (!simpleOpener.open(&amp;server))</div><div class="line">  {</div><div class="line">    <span class="keywordflow">if</span> (simpleOpener.wasUserFileBad())</div><div class="line">      printf(<span class="stringliteral">&quot;Error: Bad user/password/permissions file.\n&quot;</span>);</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">      printf(<span class="stringliteral">&quot;Error: Could not open server port. Use -help to see options.\n&quot;</span>);</div><div class="line">    exit(1);</div><div class="line">  }</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// This is the service that provides drawing data to the client.</span></div><div class="line">  <a class="code" href="classArServerInfoDrawings.html">ArServerInfoDrawings</a> drawings(&amp;server);</div><div class="line"></div><div class="line">  <span class="comment">// Add our custom drawings</span></div><div class="line">  drawings.addDrawing(</div><div class="line">      <span class="comment">//                shape:      color:               size:   layer:</span></div><div class="line">      <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArDrawingData.html">ArDrawingData</a>(<span class="stringliteral">&quot;polyLine&quot;</span>, <a name="_a34"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArColor.html">ArColor</a>(255, 0, 0),  2,      49),</div><div class="line">      <span class="stringliteral">&quot;exampleDrawing_Home&quot;</span>, </div><div class="line">      <span class="keyword">new</span> <a name="_a35"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArGlobalFunctor2.html">ArGlobalFunctor2&lt;ArServerClient*, ArNetPacket*&gt;</a>(&amp;<a class="code" href="drawingsExample_8cpp.html#a7c8ed01400d514a7b9105b92c325f26a">exampleHomeDrawingNetCallback</a>)</div><div class="line">  );</div><div class="line">  drawings.addDrawing(                                    </div><div class="line">      <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArDrawingData.html">ArDrawingData</a>(<span class="stringliteral">&quot;polyDots&quot;</span>, <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArColor.html">ArColor</a>(0, 255, 0), 250, 48),</div><div class="line">      <span class="stringliteral">&quot;exampleDrawing_Dots&quot;</span>, </div><div class="line">      <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArGlobalFunctor2.html">ArGlobalFunctor2&lt;ArServerClient*, ArNetPacket*&gt;</a>(&amp;<a class="code" href="drawingsExample_8cpp.html#a829cc347fa8f03be4f7e21f52a56b23d">exampleDotsDrawingNetCallback</a>)</div><div class="line">  );</div><div class="line">  drawings.addDrawing(</div><div class="line">      <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArDrawingData.html">ArDrawingData</a>(<span class="stringliteral">&quot;polySegments&quot;</span>, <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArColor.html">ArColor</a>(0, 0, 0), 4, 52),</div><div class="line">      <span class="stringliteral">&quot;exampleDrawing_XMarksTheSpot&quot;</span>, </div><div class="line">      <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArGlobalFunctor2.html">ArGlobalFunctor2&lt;ArServerClient*, ArNetPacket*&gt;</a>(&amp;<a class="code" href="drawingsExample_8cpp.html#ae35734c611c1c0f5e9bc6287f5eee070">exampleXDrawingNetCallback</a>)</div><div class="line">  );</div><div class="line">  drawings.addDrawing(</div><div class="line">      <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArDrawingData.html">ArDrawingData</a>(<span class="stringliteral">&quot;polyArrows&quot;</span>, <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArColor.html">ArColor</a>(255, 0, 255), 500, 100),</div><div class="line">      <span class="stringliteral">&quot;exampleDrawing_Arrows&quot;</span>, </div><div class="line">      <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArGlobalFunctor2.html">ArGlobalFunctor2&lt;ArServerClient*, ArNetPacket*&gt;</a>(&amp;<a class="code" href="drawingsExample_8cpp.html#abab39eb1a7fa3903841c77dabeb465f9">exampleArrowsDrawingNetCallback</a>)</div><div class="line">  );</div><div class="line"></div><div class="line">  <a class="code" href="classCircle.html">Circle</a> circle(&amp;drawings, <span class="stringliteral">&quot;exampleDrawing_circle&quot;</span>, </div><div class="line">    <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArDrawingData.html">ArDrawingData</a>(<span class="stringliteral">&quot;polySegments&quot;</span>, <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArColor.html">ArColor</a>(255, 150, 0), 3, 120));</div><div class="line">  circle.setPos(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArPose.html">ArPose</a>(0, -5000));</div><div class="line">  circle.setRadius(1000);</div><div class="line">  circle.setNumPoints(360);</div><div class="line"></div><div class="line">  <span class="comment">// log whatever we wanted to before the runAsync</span></div><div class="line">  simpleOpener.checkAndLog();</div><div class="line"></div><div class="line">  <span class="comment">// run the server thread in the background</span></div><div class="line">  server.<a name="a36"></a><a class="code" href="classArServerBase.html#a93c742ddc58a8f035a0d1b9c1fae4599">runAsync</a>();</div><div class="line"></div><div class="line">  printf(<span class="stringliteral">&quot;Server is now running...\n&quot;</span>);</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// Add a key handler mostly that windows can exit by pressing</span></div><div class="line">  <span class="comment">// escape, note that the key handler prevents you from running this program</span></div><div class="line">  <span class="comment">// in the background on Linux.</span></div><div class="line">  <a name="_a37"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArKeyHandler.html">ArKeyHandler</a> *keyHandler;</div><div class="line">  <span class="keywordflow">if</span> ((keyHandler = <a name="a38"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a5b8042b38b19d6a5d3cfbed4df483e67">Aria::getKeyHandler</a>()) == NULL)</div><div class="line">  {</div><div class="line">    keyHandler = <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArKeyHandler.html">ArKeyHandler</a>;</div><div class="line">    <a name="a39"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a9e5496a4ec2c379c8e18706922b57cc1">Aria::setKeyHandler</a>(keyHandler);</div><div class="line">    printf(<span class="stringliteral">&quot;To exit, press escape.\n&quot;</span>);</div><div class="line">  }</div><div class="line"></div><div class="line"> </div><div class="line">  <span class="keywordtype">double</span> circleRadius = 1000;</div><div class="line">  <span class="keywordflow">while</span>(<span class="keyword">true</span>) </div><div class="line">  {</div><div class="line">    <a name="a40"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#ga4dfb878a3f9123b8dd96ae05b2fd94cb">ArUtil::sleep</a>(100);</div><div class="line">    circleRadius += 50;</div><div class="line">    <span class="keywordflow">if</span>(circleRadius &gt; 5000)</div><div class="line">      circleRadius = 0;</div><div class="line">    circle.setRadius(circleRadius);</div><div class="line">  }</div><div class="line"></div><div class="line">  <a name="a41"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a184602a2b3799d61569ec55dd9508450">Aria::shutdown</a>();</div><div class="line">  exit(0);  </div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Network callbacks for drawings&#39; current geometry data:</span></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> <a class="code" href="drawingsExample_8cpp.html#a7c8ed01400d514a7b9105b92c325f26a">exampleHomeDrawingNetCallback</a>(<a class="code" href="classArServerClient.html">ArServerClient</a>* client, <a class="code" href="classArNetPacket.html">ArNetPacket</a>* requestPkt) {</div><div class="line">  <a class="code" href="classArNetPacket.html">ArNetPacket</a> reply;</div><div class="line"></div><div class="line">  <span class="comment">// 7 Vertices</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(7);</div><div class="line"></div><div class="line">  <span class="comment">// Centered on 0,0.</span></div><div class="line">  <span class="comment">// X:                    Y:</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-500);  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(500);   <span class="comment">// Vertex 1</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-500);  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-500);  <span class="comment">// Vertex 2</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(500);   reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-500);  <span class="comment">// Vertex 3</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(500);   reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(500);   <span class="comment">// Vertex 4</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(0);     reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(1000);  <span class="comment">// Vertex 5</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-500);  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(500);   <span class="comment">// Vertex 6</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(500);   reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(500);   <span class="comment">// Vertex 7</span></div><div class="line"></div><div class="line">  client-&gt;<a class="code" href="classArServerClient.html#a9276b1f38501725852c779058bad1d33">sendPacketUdp</a>(&amp;reply);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> <a class="code" href="drawingsExample_8cpp.html#a829cc347fa8f03be4f7e21f52a56b23d">exampleDotsDrawingNetCallback</a>(<a class="code" href="classArServerClient.html">ArServerClient</a>* client, <a class="code" href="classArNetPacket.html">ArNetPacket</a>* requestPkt) {</div><div class="line">  <a class="code" href="classArNetPacket.html">ArNetPacket</a> reply;</div><div class="line"></div><div class="line">  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> tik = <a name="a42"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArUtil.html#ad3496dfd2693d19553a399883a4e20e1">ArUtil::getTime</a>() % 200;</div><div class="line">  <span class="keywordtype">double</span> t = tik / 5.0;</div><div class="line"></div><div class="line">  <span class="comment">// Three dots</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(3);</div><div class="line"></div><div class="line">  <span class="comment">// Dot 1:</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(3000);  <span class="comment">// X coordinate (mm)</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>((<span class="keywordtype">int</span>) (<a name="a43"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#gaeb05754b7747988dd97a961eaded6830">sin</a>(t) * 1000));<span class="comment">// Y</span></div><div class="line"></div><div class="line">  <span class="comment">// Dot 2:</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(3500);  <span class="comment">// X</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>((<span class="keywordtype">int</span>) (<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#gaeb05754b7747988dd97a961eaded6830">sin</a>(t+500) * 1000));<span class="comment">// Y</span></div><div class="line"></div><div class="line">  <span class="comment">// Dot 3:</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(4000);  <span class="comment">// X</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>((<span class="keywordtype">int</span>) (<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#gaeb05754b7747988dd97a961eaded6830">sin</a>(t+1000) * 1000));<span class="comment">// Y</span></div><div class="line"></div><div class="line">  client-&gt;<a class="code" href="classArServerClient.html#a9276b1f38501725852c779058bad1d33">sendPacketUdp</a>(&amp;reply);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> <a class="code" href="drawingsExample_8cpp.html#ae35734c611c1c0f5e9bc6287f5eee070">exampleXDrawingNetCallback</a>(<a class="code" href="classArServerClient.html">ArServerClient</a>* client, <a class="code" href="classArNetPacket.html">ArNetPacket</a>* requestPkt) {</div><div class="line">  <a class="code" href="classArNetPacket.html">ArNetPacket</a> reply;</div><div class="line"></div><div class="line">  <span class="comment">// X marks the spot. 2 line segments, so 4 vertices:</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(4);</div><div class="line"></div><div class="line">  <span class="comment">// Segment 1:</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-4250); <span class="comment">// X1</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(250);   <span class="comment">// Y1</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-3750); <span class="comment">// X2</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-250);  <span class="comment">// Y2</span></div><div class="line"></div><div class="line">  <span class="comment">// Segment 2:</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-4250); <span class="comment">// X1</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-250);  <span class="comment">// Y1</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(-3750); <span class="comment">// X2</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(250);   <span class="comment">// Y2</span></div><div class="line">  </div><div class="line">  client-&gt;<a class="code" href="classArServerClient.html#a9276b1f38501725852c779058bad1d33">sendPacketUdp</a>(&amp;reply);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> <a class="code" href="drawingsExample_8cpp.html#abab39eb1a7fa3903841c77dabeb465f9">exampleArrowsDrawingNetCallback</a>(<a class="code" href="classArServerClient.html">ArServerClient</a>* client, <a class="code" href="classArNetPacket.html">ArNetPacket</a>* requestPkt) {</div><div class="line">  <span class="comment">// 1 Arrow that points at the robot</span></div><div class="line">  <a class="code" href="classArNetPacket.html">ArNetPacket</a> reply;</div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(1);</div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(0);      <span class="comment">// Pos. X</span></div><div class="line">  reply.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArBasePacket.html#a6ab2c8b1224dc27fc96f22ff8f027e28">byte4ToBuf</a>(700);   <span class="comment">// Pos. Y</span></div><div class="line">  client-&gt;<a class="code" href="classArServerClient.html#a9276b1f38501725852c779058bad1d33">sendPacketUdp</a>(&amp;reply);</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
